using System.IO;
using System.Collections;
using Framework;
using UnityEngine;

public class GamePreload : FsmStateAction
{
    protected override void OnEnter()
    {
        base.OnEnter();
        GameEntry.GUI.Open(GameEntry.GUIPath.LoadingUI);
        GameEntry.Coroutine.Start(loadTable(), "preload");
        GameEntry.Coroutine.Start(GameEntry.Table.Load(GameEntry.AssetsLoader), "loadtable");
#if UNITY_EDITOR
        var path = Path.Combine(Application.dataPath, "Res/DataTable");
        if (!Directory.Exists(path))
        {
            Debug.LogError("先生成数据表");
        }
#endif

    }
    protected override void OnUpdate(float deltaTime, float progress)
    {
        base.OnUpdate(deltaTime, progress);
    }
    IEnumerator loadTable()
    {
        var count = GameEntry.Table.Count;
        while (GameEntry.Table.LoadCount < count)
        {
            yield return null;
        }
        this.Finished = true;
    }

}